package view.inventory.tip
{
import core.Language;

import flash.utils.Dictionary;

import mx.utils.StringUtil;

import utils.PropertyUtil;

import values.item.EquipmentItemValue;

/**
 * InventoryEquipmentItemTip
 * @author jliang
 *
 */
public class InventoryEquipmentItemTip extends InventoryItemTip
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function InventoryEquipmentItemTip()
	{
		super();
	}
	//==========================================================================
	//  Overridden methods: Component
	//==========================================================================			
	override protected function get textHeightOffset():Number
	{
		return 10;
	}
	
	override public function set data(value:*):void
	{
		vo = value;
		
		var item:EquipmentItemValue = value;
		
		var propertyContent:String = "";
		
		var properties:Dictionary = PropertyUtil.initPropertyMapping(item);
		for each (var obj:Object in properties)
		{
			var val:Number = item[obj.prop];
			if (val == 0)
			{
				continue;
			}
			propertyContent += "<p>" + Language.getText("@property_" + obj.prop + "_name") + ": " + (val > 0 ? "+" : "-") + val + "</p>";
		}
		
		var content:String = StringUtil.substitute(Language.getText("@equipment_tip_content"),  
																			 item.template.name,
																			 item.template.desc,
																			 item.level,
																			 1,
																			 propertyContent + " ");
		
		setText(content);
	}
}
}



